home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 May / Disc 2 / PCU0503CD2.iso / BitFax_BitWare / BitWarePro / Simply / classcap.scp < prev    next >
Encoding:
Text File  |  2001-09-05  |  10.7 KB  |  415 lines

  1. //---------------------------------------------------------
  2. // ext vars
  3. // @szATCmd  - str (LPSTR)
  4. // @szCID    - str
  5. // @szDCS    - str
  6. // @szDIS    - str
  7. // @szDCC    - str
  8. // @szHNG    - str
  9. // @szNSF    - str
  10. // @lpszRespBuff - str
  11. // @lPageCnt    - long
  12. // @lPageTotal  - long
  13. // @lSizeForNSF - long
  14. // @ComIO     
  15. // @GlStr1
  16. // @GlStr2
  17. // @RespBuffer
  18. //---------------------------------------------------------
  19.  
  20.  
  21. //---------------------------------------------------------
  22. // ext functions
  23. //fSetBaudRate(DWORD lpParam, DWORD Baud, DWORD dwN1, DWORD dwN2);
  24. //fWaitResponse(DWORD lpParam, DWORD lpBuf, DWORD lTimeOut, DWORD dwN1);
  25. //fSendATCmd(DWORD lpParam, DWORD lpBuf, DWORD dwN1, DWORD dwN2);
  26. //fSendDLE_ETX(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
  27. //fSleep(DWORD lTime, DWORD dwN1, DWORD dwN2, DWORD dwN3);
  28. //fFlushRxQueue(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
  29. //fFlushTxQueue(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
  30. //fSendOneChar(DWORD lpParam, DWORD dwCh, DWORD dwN1, DWORD dwN2);
  31. //fWaitOneChar(DWORD lpParam, DWORD lpResultChar, DWORD lTimeOut, DWORD dwN1);
  32. //fSetDTR(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
  33. //fResetDTR(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
  34. //fSetRTS(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
  35. //fResetRTS(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
  36. //fSetMisc(DWORD lpParam, DWORD nParity, DWORD nDataBits, DWORD nStopBits);
  37. //fSetMiscMore(DWORD lpParam, DWORD bDTRDSR, DWORD bRTSCTS, DWORD bXONXOFF);
  38. //fHardFlowControl(DWORD lpParam, DWORD Type, DWORD dwN1, DWORD dwN2);
  39. //fSoftFlowControl(DWORD lpParam, DWORD Type, DWORD dwN1, DWORD dwN2);
  40. //fSkipSpaceStrStr(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
  41. //fTxFirstResponseError(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
  42. //fStripChar(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
  43. //fFirstNumString(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
  44. //
  45. //   For fHardFlowControl:
  46. //     param1 - 0000X0YY   X  - Cts flow control
  47. //                         YY : 00 - RTS DISABLE
  48. //                         YY : 01 - RTS ENABLE
  49. //                         YY : 10 - RTS HANDSHAKE
  50. //                         YY : 11 - RTS TOGGLE
  51. //   For fSoftFlowControl
  52. //         FLOWCTRL_NONE 0
  53. //         FLOWCTRL_SEND 1    
  54. //         FLOWCTRL_RECV 2
  55. //         FLOWCTRL_BOTH 4
  56. //---------------------------------------------------------
  57.  
  58. //
  59. // This is the script file for Class2.
  60. //
  61. // trace
  62. declare STRING %szStr1, %szStr2;
  63. declare STRING %szStr3, %szStr4;
  64. declare STRING %szPass1, %szPass2;
  65. declare STRING %szPass3, %szPass4;
  66. declare STRING %szMsg1;
  67. declare long   %lType;
  68. declare long   %lRes;
  69. declare long   %lTemp;
  70. declare long   %lGRes;
  71. declare long   %lMsg1;
  72. declare char   %XON;
  73. declare STRING %szNULL;
  74.  
  75. //----------------------------------------------------------------------
  76. //----------------------------------------------------------------------
  77. sub  SubSendCmdWaitResp(STRING #szCmd, STRING #szResp, long #lWaitTime)
  78. declare long %lRes;
  79. declare STRING %szCheckAT;
  80.  
  81.         %szCheckAT = "AT"
  82.         %lRes = fSkipSpaceStrStr(%szCheckAT, #szCmd)
  83.         if (%lRes = 0)
  84.            {
  85.            %lRes = 0
  86.            goto SendCmd1
  87.            }
  88.  
  89.         %lRes = fSendATCmd(@ComIO, #szCmd)
  90.         if (%lRes!=0)
  91.            {
  92.            %lRes = 101
  93.            goto SendCmd1
  94.            }
  95.  
  96.  
  97. :SendCmd0
  98.         %lRes = fWaitResponse(@ComIO, #lWaitTime)
  99.         if (%lRes != 0)
  100.            {
  101.            %lRes = 101
  102.            goto SendCmd1
  103.            }
  104.  
  105.         %lRes = fSkipSpaceStrStr(#szResp, @RespBuffer)
  106.         if (%lRes != 0)
  107.            %lRes = 0
  108.         else
  109.            goto SendCmd0
  110.  
  111. :SendCmd1
  112.         %lGRes = %lRes
  113. endsub
  114.  
  115. //----------------------------------------------------------------------
  116. //----------------------------------------------------------------------
  117. :GET_CLASS1_SPEED
  118.     fSleep(300)
  119.     fFlushRxQueue(@ComIO)
  120.     fFlushTxQueue(@ComIO)
  121.     call SubSendCmdWaitResp("AT+FCLASS=1", "OK", 3000)
  122.     fSleep(300)
  123.     fSetBaudRate(@ComIO, 19200)
  124.     fFlushRxQueue(@ComIO)
  125.     fFlushTxQueue(@ComIO)
  126.     @szATCmd = "AT+FRM=?"
  127.     fSendATCmd(@ComIO, @szATCmd)
  128.     %lType = 0
  129.  
  130. :GET_CLASS1_SP0
  131.     %lRes = fWaitResponse(@ComIO, 1000) 
  132.     if (%lRes != 0)
  133.         goto GET_CLASS1_SP1
  134.  
  135.     %szStr1 = "145"
  136.     %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
  137.     if (%lRes != 0)
  138.         {
  139.         %lType = 14400
  140.         goto GET_CLASS1_SP1
  141.         }
  142.     %szStr1 = "96"
  143.     %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
  144.     if (%lRes != 0)
  145.         {
  146.         %lType = 9600
  147.         goto GET_CLASS1_SP1
  148.         }
  149.     %szStr1 = "72"
  150.     %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
  151.     if (%lRes != 0)
  152.         {
  153.         %lType = 7200
  154.         goto GET_CLASS1_SP1
  155.         }
  156.     %szStr1 = "48"
  157.     %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
  158.     if (%lRes != 0)
  159.         {
  160.         %lType = 4800
  161.         goto GET_CLASS1_SP1
  162.         }
  163.     %szStr1 = "24"
  164.     %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
  165.     if (%lRes != 0)
  166.         {
  167.         %lType = 2400
  168.         goto GET_CLASS1_SP1
  169.         }
  170.  
  171.     goto GET_CLASS1_SP0
  172.  
  173. :GET_CLASS1_SP1
  174.     fSleep(500)
  175.     fFlushRxQueue(@ComIO)
  176.     call SubSendCmdWaitResp("AT+FCLASS=0", "OK", 3000)
  177.     fSetBaudRate(@ComIO, 2400)
  178.     fFlushRxQueue(@ComIO)
  179.     fFlushTxQueue(@ComIO)
  180.     exit (%lType)
  181.  
  182.  
  183. //----------------------------------------------------------------------
  184. //----------------------------------------------------------------------
  185. :GET_FAX_CLASS
  186.     fHardFlowControl(@ComIO, 9)
  187.     fSoftFlowControl(@ComIO, 0)
  188.     fSetRTS(@ComIO)
  189.  
  190.     fSetBaudRate(@ComIO, 2400)
  191.     fFlushRxQueue(@ComIO)
  192.     fFlushTxQueue(@ComIO)
  193.     fSleep(300)
  194.  
  195.     call SubSendCmdWaitResp("AT", "OK", 500)
  196.     fSleep(500)
  197.     fFlushRxQueue(@ComIO)
  198.  
  199.     call SubSendCmdWaitResp("AT", "OK", 500)
  200.     fSleep(300)
  201.     fFlushRxQueue(@ComIO)
  202.  
  203.     @szATCmd = "ATE0V1"
  204.     fSendATCmd(@ComIO, @szATCmd)
  205.     fSleep(300)
  206.     fFlushRxQueue(@ComIO)
  207.  
  208.  
  209. //    @szATCmd = "ATS0=0H0"
  210. //    fSendATCmd(@ComIO, @szATCmd)
  211. //    fSleep(1000)
  212. //    fFlushRxQueue(@ComIO)
  213. //
  214. //    @szATCmd = "ATE0V1&C1H0"
  215. //    fSendATCmd(@ComIO, @szATCmd)
  216. //    fSleep(1000)
  217. //    fFlushRxQueue(@ComIO)
  218. //
  219.  
  220.  
  221.     call SubSendCmdWaitResp("ATZ", "OK", 3000)
  222.     fSleep(1000)
  223.     fFlushRxQueue(@ComIO)
  224.  
  225.     call SubSendCmdWaitResp("ATE0V1", "OK", 3000)
  226.     fSleep(150)
  227.     fFlushRxQueue(@ComIO)
  228.  
  229.     call SubSendCmdWaitResp("ATS0=0H0E0", "OK", 3000)
  230.     fSleep(150)
  231.     fFlushRxQueue(@ComIO)
  232.  
  233.     call SubSendCmdWaitResp("ATE0V1&C1H0", "OK", 3000)
  234.     fSleep(150)
  235.     fFlushRxQueue(@ComIO)
  236.  
  237.  
  238.     fFlushTxQueue(@ComIO)
  239.     if (%lGRes != 0)
  240.        exit (1000)      // No modem exists. Return any number greater 512
  241.  
  242.     fFlushTxQueue(@ComIO)
  243.     fFlushRxQueue(@ComIO)
  244.     @szATCmd = "AT+FCLASS=?"
  245.     fSendATCmd(@ComIO, @szATCmd)
  246.     %lType  = 0
  247.  
  248. :GET_FAX_CLASS1
  249.     %lRes = fWaitResponse(@ComIO, 3000) 
  250.     if (%lRes != 0)
  251.         {
  252.         exit (%lType)
  253.     }
  254.  
  255.     // Yes, sth is the buffer, we need to compare it
  256.     %szStr3 = "OK"
  257.     %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
  258.     if (%lRes != 0)
  259.         {
  260.         exit (%lType)            // OK
  261.         }
  262.  
  263.     %szStr3 = "1"
  264.     %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
  265.     if (%lRes != 0)
  266.        { 
  267.        %lType = %lType + 1
  268.        }
  269.  
  270.     %szStr3 = "2.0"
  271.     %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
  272.     if (%lRes != 0)
  273.        { 
  274.        %lType = %lType + 4
  275.        %szStr3 = "2,"
  276.        %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
  277.        if (%lRes != 0)
  278.           %lType = %lType + 2
  279.        }
  280.     else
  281.        {
  282.        %szStr3 = "2"
  283.        %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
  284.        if (%lRes != 0)
  285.           %lType = %lType + 2
  286.        }
  287.  
  288.     goto GET_FAX_CLASS1
  289.  
  290.  
  291. //--------------------------------------------------------
  292. // Class 1   is 1
  293. // Class 2   is 2
  294. // Class 2.0 is 4
  295. //--------------------------------------------------------
  296. :GET_FAX_PREFRENCE
  297.     exit(2)
  298.  
  299. //----------------------------------------------------------------------
  300. // The result are return as dec. 
  301. // dec 48   - Hex 0x30
  302. // dec 49   - Hex 0x31
  303. // dec 50   - Hex 0x32
  304. // dec 51   - Hex 0x33
  305. // dec 52   - Hex 0x34
  306. // dec 53   - Hex 0x35
  307. // dec 54   - Hex 0x36
  308. // dec 55   - Hex 0x37
  309. // dec 56   - Hex 0x38
  310. // dec 57   - Hex 0x39
  311. //----------------------------------------------------------------------
  312. :FAX_CAPABILITY_MAIN
  313.     fSleep(400)
  314.     fFlushTxQueue(@ComIO)
  315.     fFlushRxQueue(@ComIO)
  316.     @szATCmd = "AT+FDCC=?"
  317.     fSendATCmd(@ComIO, @szATCmd)
  318.     %lType  = 0
  319.     %szStr1 = ""
  320.  
  321.     // wait for response
  322.     %lRes = fWaitResponse(@ComIO, 3000) 
  323.     if (%lRes != 0)
  324.     {
  325.         exit (%lType)
  326.     }
  327.  
  328.     fParseFaxClassCap(@RespBuffer, %szStr1)
  329.     fSleep(300)
  330.     fFlushTxQueue(@ComIO)
  331.     fFlushRxQueue(@ComIO)
  332.     exit (%lType)
  333.  
  334.  
  335. :FAX_CAPABILITY_VR
  336. //
  337. //  szStr1 is the source
  338. //
  339. //  %lType = 49  
  340.     %szStr2 = substr(%szStr1, 0, 1)
  341.     %lType  = fCharToInt(%szStr2)  
  342.     exit (%lType)
  343.  
  344. :FAX_CAPABILITY_BR
  345.  // %lType = 51  
  346.     %szStr2 = substr(%szStr1, 1, 2)
  347.     %lType  = fCharToInt(%szStr2)  
  348.     exit (%lType)
  349.  
  350. :FAX_CAPABILITY_WD
  351. //  %lType = 48  
  352.     %szStr2 = substr(%szStr1, 2, 3)
  353.     %szStr2 = fCharToInt()
  354.     %lType  = fCharToInt(%szStr2)  
  355.     exit (%lType)
  356.  
  357. :FAX_CAPABILITY_LN
  358. //  %lType = 50  
  359.     %szStr2 = substr(%szStr1, 3, 4)
  360.     %lType  = fCharToInt(%szStr2)  
  361.     exit (%lType)
  362.  
  363. :FAX_CAPABILITY_DF
  364. //  %lType = 48  
  365.     %szStr2 = substr(%szStr1, 4, 5)
  366.     %lType  = fCharToInt(%szStr2)  
  367.     exit (%lType)
  368.  
  369. :FAX_CAPABILITY_EC
  370. //  %lType = 48  
  371.     %szStr2 = substr(%szStr1, 5, 6)
  372.     %lType  = fCharToInt(%szStr2)  
  373.     exit (%lType)
  374.  
  375. :FAX_CAPABILITY_BF
  376. //  %lType = 48  
  377.     %szStr2 = substr(%szStr1, 6, 7)
  378.     %lType  = fCharToInt(%szStr2)  
  379.     exit (%lType)
  380.  
  381.  
  382.  
  383.  
  384. //----------------------------------------------------------------------
  385. //----------------------------------------------------------------------
  386. :GET_CLASS20_SPEED
  387.     fSleep(400)
  388.     fFlushRxQueue(@ComIO)
  389.     fFlushTxQueue(@ComIO)
  390.     call SubSendCmdWaitResp("AT+FCLASS=2.0", "OK", 3000)
  391.     fSetBaudRate(@ComIO, 19200)
  392.     fSleep(400)
  393.     fFlushRxQueue(@ComIO)
  394.     fFlushTxQueue(@ComIO)
  395.     @szATCmd = "AT+FCC=?"
  396.     fSendATCmd(@ComIO, @szATCmd)
  397.     %lType = 0
  398.  
  399. :GET_CLASS20_SP0
  400.     %lRes = fWaitResponse(@ComIO, 1000) 
  401.     if (%lRes != 0)
  402.         goto GET_CLASS20_SP1
  403.  
  404.     fParseFaxClassCap(@RespBuffer, %szStr1)
  405.  
  406. :GET_CLASS20_SP1
  407.     fSleep(500)
  408.     fFlushRxQueue(@ComIO)
  409.     call SubSendCmdWaitResp("AT+FCLASS=0", "OK", 3000)
  410.     fSetBaudRate(@ComIO, 2400)
  411.     fFlushRxQueue(@ComIO)
  412.     fFlushTxQueue(@ComIO)
  413.     exit (%lType)
  414.  
  415.